%%
%% wdok-title
%% @(#) Time-stamp: <2005-04-20T17:36:45 mxp>
%% Created by Michael Piotrowski <mxp@iws.cs.uni-magdeburg.de>

%% NOTE:  This package is only usable with the mparticle and mpreport
%% classes because it uses variables defined there (prefixed with mp@).

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{wbook-title}[2005/01/10 Title page for WDOK theses]

\RequirePackage{graphicx}
\RequirePackage{ifthen}
\RequirePackage{keyval}

%% To add flexibility, we will not use the ordinary processing of
%% package options, but put them through the |keyval| package.
%% This section is from the |hyperref| package.
\def\ProcessOptionsWithKV#1{%
  \let\@tempa\@empty
  \@for\CurrentOption:=\@classoptionslist\do{%
    \@ifundefined{KV@#1@\CurrentOption}%
    {}%
    {\edef\@tempa{\@tempa,\CurrentOption,}}}%
  \edef\@tempa{%
    \noexpand\setkeys{#1}{\@tempa\@ptionlist{\@currname.\@currext}}}%
  \@tempa
  \AtEndOfPackage{\let\@unprocessedoptions\relax}}

%% Declare the options.
\newcommand{\@wbooktitlelang}{de}
\define@key{wbooktitle}{lang}{\renewcommand{\@wbooktitlelang}{#1}}

%% Process them.
\ProcessOptionsWithKV{wbooktitle}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ifthenelse{\equal{\@wbooktitlelang}{en}}%
{\newcommand{\@supervisortext}{Supervisors}}%
{\newcommand{\@supervisortext}{Betreuer}}

\ifthenelse{\equal{\@wbooktitlelang}{en}}%
{\newcommand{\@readertext}{Reader}}%
{\newcommand{\@readertext}{Gutachter}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\thesisname}[1]{\def\@thesisname{#1}}
\newcommand{\university}[1]{\def\@university{#1}}
\newcommand{\faculty}[1]{\def\@faculty{#1}}
\newcommand{\department}[1]{\def\@department{#1}}
\newcommand{\supervisor}[1]{\def\@supervisor{#1}}
\newcommand{\supervisortext}[1]{\def\@supervisortext{#1}}
\newcommand{\reader}[1]{\def\@reader{#1}}
\newcommand{\readertext}[1]{\def\@readertext{#1}}
\newcommand{\addr}[1]{\def\@addr{#1}}
\newcommand{\logo}[1]{\def\@logo{#1}}

\renewcommand{\maketitle}{%
  \begin{titlepage}%
    %%
    \par\hspace{-\mp@margwd}%
    \unitlength1mm
    \begin{picture}(-2,12)
      \put(-1,11){\rule{\mp@fullwd}{1mm}}

      \put(-4,-17){
        \parbox[b]{170mm}{
          \raggedleft{
            \fontsize{14}{18}\selectfont
            \MakeUppercase{\@university}\\
            ~\\
            \fontfamily{ptm}\fontsize{12}{14}\selectfont \MakeUppercase{\@faculty}\\
            \@department\\
            ~\\
          }%
        }%
      }%
      \put(0,-20){\includegraphics[height=30mm]{\@logo}}
      %\put(145,-20){\includegraphics[height=30mm]{\@logo}}
      \put(25,-20){\rule{144mm}{.25mm}}
    \end{picture}
    
    %% typeset the title
    \vspace{5cm}
    \begin{flushleft}
      \sffamily\huge
      \@thesisname\vskip 1ex
      \LARGE
      \emph{\@title}\vskip 1ex
      \normalsize
      \@author\vskip 2ex
      \@date
      \vspace{1cm}
      \@ifundefined{@supervisor}{}
      {
        \par
        \textbf{\@supervisortext}\\
        \@supervisor
      }
      \@ifundefined{@reader}{}
      {
        \par
        \textbf{\@readertext}\\
        \@reader
      }
      %%
      \vfill
      \@university\\
      \@faculty\\
      \@addr\\
    \end{flushleft}

    \hspace{-\mp@margwd}%
    \rule{\mp@margwd}{2.25mm}%
    \hspace{-\mp@margwd}%
    \rule{\mp@fullwd}{.25mm}%
  \end{titlepage}%
}
